package com.bi.bitest.bao.utils;

import android.content.Context;
import android.content.res.Resources;
import android.util.DisplayMetrics;

/**
 * Created
 * Author:bi[FR]
 * Date:15-10-22
 */
public final class DimensionUtil {
    private DimensionUtil(){

    }
    /**
     * 根据手机的屏幕密度进行dp到px的换算
     * @param context
     * @param dp
     * @return
     */
    public static int dp2px(Context context,int dp){
        int ret=0;
        Resources res=context.getResources();
        //获取屏幕的测量信息
        DisplayMetrics metrics=res.getDisplayMetrics();
        //px = dp * (dpi / 160)
         ret= (int) (dp*metrics.density);
        return ret;
    }




}
